#!/usr/bin/env bash

set -eo

rm -rf /tmp/built-in
mkdir -p /tmp/built-in
version=$(cat resources/CLJ_KONDO_VERSION)
echo "$version"

# shellcheck disable=1091
source script/extract-versions

clojure -M:clj-kondo/dev --lint "$CLJ_KONDO_EXTRACT_CORE_DEPS_PATH" --cache /tmp/built-in --dependencies

base_path="/tmp/built-in/v1"

rm "$base_path"/clj/clojure.tools.reader.*.transit.json
rm "$base_path"/cljs/cljs.tools.reader.*transit.json

cp "$base_path"/clj/clojure.*.transit.json resources/clj_kondo/impl/cache/built_in/clj
cp "$base_path"/cljs/cljs.*.transit.json resources/clj_kondo/impl/cache/built_in/cljs
cp "$base_path"/cljs/clojure.*.transit.json resources/clj_kondo/impl/cache/built_in/cljs
cp "$base_path"/cljc/cljs.*.transit.json resources/clj_kondo/impl/cache/built_in/cljc

script/dump_types.clj
